﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

using MyDHServer.Contorls;
namespace MyDHServer.Contorls.admin
{
    public class AdminNavBar :  MenuItemBaseControl
    {
        private Repeater NavList;
        public AdminNavBar()
        {

        }
        protected override string SkinFolder
        {
            get
            {
                return "~/Skin/admin/Controls/";
            }
        }
        
        protected override void AttachChildControls()
        {
            NavList = FindControl("NavList") as Repeater;
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.DataBind();
        }

        public override void DataBind()
        {
            base.DataBind();

            NavList.DataSource = GetMenus();
            NavList.DataBind();
        }

        private List<MenuItem> GetMenus()
        {
            List<MenuItem> Menulist = new List<MenuItem>();
            MenuItemCollection Mc = base.GetMenuItems();

            foreach (MenuItem item in Mc.MenuItems)
            {
                Menulist.Add(item);
            }

            return Menulist;
        }
    }
}
